﻿using HBKY.Shop.Common.Helper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;

namespace HBKY.Shop.Extensions.Middleware
{
    public static class MiddlewareHelper
    {  
        /// <summary>
        /// 请求响应中间件
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static IApplicationBuilder UseHttpLog(this IApplicationBuilder app)
        {
            return app.UseMiddleware<HttpLogMiddleware>();
        }

        /// <summary>
        /// 健康检查
        /// </summary>
        public static void UseHealthCheckMildd(this IApplicationBuilder app)
        {
            return;
            if (app == null) throw new ArgumentNullException(nameof(app));
            string pathMatch = $"/{Appsettings.Option("Startup", "RoutePrefix")}/monitor/do";
            app.Map(pathMatch, builder => builder.Run(async context =>
            {
                context.Response.ContentType = "text/html; charset=utf-8";
                await context.Response.WriteAsync("It's OK!");
            }));
        }
    }
}
